import requset from "../utils/requset"



// 徐流洋的数据报表的接口
export let Eractor = () => {
    return requset({
        url: "reports/type/1",
        method: "get"
    })
}



// 登录接口
export let Login = (data) => {
    return requset({
        url: "login",
        method: "post",
        data
    })
}


//刘欣怡获取世界地图的接口
import axios from "axios"
const http_1 = axios.create({
    baseURL: 'http://localhost:8090',
    timeout: 8000,
});
export const getCovData = () => http_1.get('/data')




// 张北寒获取权限列表的接口
export let JuList = () => {
    return requset({
        url: "rights/list",
        method: "get"
    })
}

//商品分类列表
// export const getGoods = (val) => {
//     return requset({
//         url:"goods",
//         method:"get",
//         params:{
//             pagenum:1,
//             pagesize :5
//         }
//     })
//     // console.log(val);
// }

// 张北寒商品列表
export let ComLis = (val, vals) => {
    console.log("页" + val, "条" + vals);
    return requset({
        url: "goods",
        method: "get",
        params: {
            pagenum: val,
            pagesize: vals
        }
    })
}

// 用户列表数据
export let userlist = (val) => {
    return requset({
        url: "users",
        method: "get",
        params: {
            pagenum: val,
            pagesize: 10
        }
    })
}

//商品管理分类参数
export const getParameter = () => {
    return requset({
        url: "categories",
        method: "get"
    })
}

export const getParameter2 = () => {
    return requset({
        url: "categories?type=2",
        method: "get"
    })
}
//商品管理分类参数列表
export const getParameterList = (value, str) => {
    return requset({
        url: "categories/" + value + "/attributes",
        method: "get",
        params: {
            sel: str
        }
    })
}

//商品管理分类添加动态参数或者静态属性
export const addParameter = (id, str, name) => {
    return requset({
        url: "categories/" + id + "/attributes",
        method: "post",
        data: {
            attr_name: name,
            attr_sel: str,
        }
    })
}

//商品管理分类删除参数
export const deleteParameter = (id, attrid) => {
    return requset({
        url: "categories/" + id + "/attributes/" + attrid,
        method: "delete"
    })
}

//商品管理分类编辑参数
export const putParameter = (id, attrid, value, str) => {
    return requset({
        url: "categories/" + id + "/attributes/" + attrid,
        method: "put",
        data: {
            attr_name: value,
            attr_sel: str
        }
    })
}

//添加分类
export const addFenlei = (pid, catName) => {
    return requset({
        url: "categories",
        method: "post",
        data: {
            cat_pid: pid,
            cat_name: catName,
            cat_level: 2
        }
    })
}

//删除分类
export const deleteFenlei = (id) => {
    return requset({
        url: "categories/" + id,
        method: "delete"
    })
}

//编辑分类
export const bianjiFenlei = (id, catName) => {
    return requset({
        url: "categories/" + id,
        method: "put",
        data: {
            cat_name: catName
        }
    })
}

//分类分页
export const fenleiFenye = (pagenum, pagesize) => {
    return requset({
        url: "categories",
        method: "get",
        params: {
            pagenum,
            pagesize
        }
    })
}

// 张北寒商品列表删除
export let Remover = (id) => {
    console.log(id);
    return requset({
        url: "goods/" + id,
        method: "delete",
    })
}


// 张北寒请求添加商品中的基本信息中的三级列表
export let Add = () => {
    return requset({
        url: "categories",
        method: "get",
    })
}

// 张北寒商品参数
export let AddClass = (id) => {
    return requset({
        url: "categories/" + id + "/attributes?sel=many",
        method: "get"
    })
}

// 张北寒商品属性
export let posrt = (id) => {
    return requset({
        url: "categories/" + id + "/attributes?sel=only",
        method: "get"
    })
}

// 张北寒添加商品
export let Ass = (Comname, Comparet, Comnumber, Commentbig, index) => {
    return requset({
        url: "goods",
        method: "post",
        data: {
            "goods_name": Comname,
            "goods_cat": index,
            "goods_price": Comparet,
            "goods_number": Comnumber,
            "goods_weight": Commentbig,
        }
    })
}


// 张北寒搜索
export let search1 = (val, vals, scher) => {
    return requset({
        url: "goods",
        method: "get",
        params: {
            query: scher,
            pagenum: val,
            pagesize: vals
        }
    })
}

// 添加用户
export let adduser = (obj) => {
    return requset({
        url: "users",
        method: "post",
        data: obj
    })
}

// 编辑用户
export let edituser = (obj) => {
    return requset({
        url: "users/" + obj.id,
        method: "put",
        data: {
            email: obj.email,
            mobile: obj.mobile
        }
    })
}


// 删除用户

export let omituser = (id) => {
    return requset({
        url: "users/" + id,
        method: "delete"
    })
}

// 角色列表数据

export let roleList = () => {
    return requset({
        url: "roles",
        method: "get"
    })
}

// 添加角色数据

export let addrole = (obj) => {
    return requset({
        url: "roles",
        method: "post",
        data: obj
    })
}

// 编辑角色数据

export let editrole = (obj) => {
    return requset({
        url: "roles/" + obj.id,
        method: "put",
        data: {
            roleName: obj.roleName,
            roleDesc: obj.roleDesc
        }
    })
}

// 删除角色数据

export let omitrole = (id) => {
    return requset({
        url: "roles/" + id,
        method: "delete",
    })
}


// 搜索用户数据

export let search = (val) => {
    return requset({
        url: "users/",
        method: "get",
        params: {
            query: val,
            pagenum: 1,
            pagesize: 10,
        }
    })
}

//订单管理-列表接口
export let OrderList = (tag, size) => {
    console.log(tag);
    return requset({
        url: "orders",
        method: "get",
        params: {
            pagenum: tag,
            pagesize: size
        }
    })
}

export let Logistics = () => {
    return requset({
        url: "kuaidi/" + 58,
        method: "get",
    })
}